package com.aptemo.webetek.server.handlers;

import com.aptemo.webetek.client.commands.Action;
import com.aptemo.webetek.client.commands.impl.GetPlayersPagingAction;
import com.aptemo.webetek.client.exceptions.BackendException;
import com.aptemo.webetek.client.exceptions.WebetekLoginException;
import com.aptemo.webetek.server.datastore.DataStoreAPI;
import com.aptemo.webetek.shared.PagingResult;
import com.aptemo.webetek.shared.UserBean;

public class PlayersPagingHandler
		extends ActionHandler<GetPlayersPagingAction, PagingResult<UserBean>>
{

	public PlayersPagingHandler(DataStoreAPI dataService)
	{
		super(dataService);
	}

	public Class<? extends Action<?>> getActionType()
	{
		return GetPlayersPagingAction.class;
	}

	@Override
	public PagingResult<UserBean> invoke(GetPlayersPagingAction action) throws BackendException, WebetekLoginException
	{
		utils.checkLogin();

		return dataService.getPlayers(action.getTeamId(), action.getStatus(), action.getOrder(), action.getCursor(), action.getPageSize());
	}

}
